(function () {
    angular.module('app')
        .component('xxRegister', {
            templateUrl: '/app/register/register.html',
            controller: ctrl
        });

    function ctrl($scope,$state,$mdDialog,urlCnst,RegisterFactory) {
        $scope.status = '  ';
        $scope.customFullscreen = false;
        $scope.user = {
            username:"",
            password:"",
            realName:'',
            phone:"",
            //birthday:"",
            native:'',
            education:'',
        };
        $scope.register = function (body) {
            if(!body['username']||!body['password']||!body['realName']
                ||!body['native']||!body['education']||!body['birthday']){
                urlCnst.notice('请将信息填写完整');
                return;
            }
            if(body['birthday'])body.birthday = + body.birthday;
            function cb(err,res) {
                if(!err)urlCnst.notice('注册成功');//$state.go('show.home');
                //console.log(err,res);
            }
            RegisterFactory.register(body,cb);
        }
        $scope.home = function () {
            $state.go('show.home')
        }
        $scope.registerCon = function () {
            $state.go('registerCon')
        }
    }
})();
